package com.yztc.orangeentertainment.ui.main.findfragment.findadapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yztc.orangeentertainment.R;
import com.yztc.orangeentertainment.bean.findbean.FindWewatchBean;
import com.yztc.orangeentertainment.ui.main.channalarticle.ChannalArticleActivity;

import java.util.List;

/**
 * Created by My on 2016/10/7.
 */
public class FindRlvAdapter extends RecyclerView.Adapter<FindRlvAdapter.MyViewHolder> {
    private Context context;
    private List<FindWewatchBean> list;

    public FindRlvAdapter(Context context, List<FindWewatchBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder holder = new MyViewHolder(LayoutInflater.from(context).inflate(R.layout
                .find_recyclerview, null));
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        holder.tv.setText(list.get(position).getTitle());
        holder.tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, ChannalArticleActivity.class);
                intent.putExtra("id", list.get(position).getId() + "");
                context.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        private TextView tv;

        public MyViewHolder(View itemView) {
            super(itemView);
            tv = (TextView) itemView.findViewById(R.id.rlv_tv);
        }
    }
}
